package com.mdb.open.trade.utils;

import java.math.BigDecimal;
import java.math.RoundingMode;

/**
 * @description:
 * @author: you.yichao
 * @create: 2019-07-12 18:02
 **/

public class AmountCalcUtils {

    public static final Integer YEAR = 360;

    public static BigDecimal calcExpectedInterest(BigDecimal principal, Integer loanTerm, BigDecimal rate) {

        BigDecimal expectedInterest = principal.multiply(rate.multiply(new BigDecimal("0.01")))
                .multiply(new BigDecimal(loanTerm)).divide(new BigDecimal(YEAR), 2, RoundingMode.HALF_UP);

        return expectedInterest;
    }

    public static BigDecimal calcExpectedApplyAmount(BigDecimal customsAmount, BigDecimal deposit) {

        return customsAmount.subtract(deposit != null ? deposit : BigDecimal.ZERO)
                .multiply(new BigDecimal("0.9")).setScale(2, RoundingMode.HALF_UP);

    }
}
